package com.example.aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
//@Aspect
//@Component

public class AspectDemo {
    @Pointcut("execution(* com.example.aop.controller.*.*(..))")
    private void pt(){}

    @Around("pt()")
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
        log.info("doAround 前");

        Object result = pjp.proceed();

        log.info("doAround 后");
        return result;
    }
    @Before("pt()")
    public void doBefore(){
        log.info("doBefore ...");
    }
    @After("pt()")
    public void doAfter(){
        log.info("doAfter ...");
    }
    @AfterReturning("pt()")
    public void doAfterReturning(){
        log.info("doAfterReturning ...");
    }
    @AfterThrowing("pt()")
    public void doAfterThrowing(){
        log.info("doAfterThrowing ...");
    }
}



























